package com.heima.article.controller.v1;

import com.heima.article.service.AuthorService;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("作者api")
@RestController
@RequestMapping("/api/v1/author")
public class AuthorController {

    @Autowired
    private AuthorService authorService;

    @ApiOperation("根据id查询作者")
    @GetMapping("/findByUserId/{id}")
    public ResponseResult findAuthorByUserId(@PathVariable("id") Integer id) {
        return authorService.findAuthorById(Long.valueOf(id));
    }

    @ApiOperation("新增作责信息")
    @PostMapping("/save")
    public ResponseResult addAuthor(@RequestBody ApAuthor apAuthor) {
        return authorService.addAuthor(apAuthor);
    }
}
